<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>任务管理清单</title>
    <style>
        body {
            max-width: 600px;
            margin: 50px auto;
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
        }

        .todo-container {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }

        .input-group {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

        #taskInput {
            flex: 1;
            padding: 12px;
            border: 2px solid #ddd;
            border-radius: 6px;
            font-size: 16px;
        }

        #addButton {
            padding: 12px 24px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        #addButton:hover {
            background-color: #45a049;
        }

        #taskList {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .task-item {
            display: flex;
            align-items: center;
            padding: 15px;
            background-color: #f8f9fa;
            margin-bottom: 8px;
            border-radius: 6px;
            transition: transform 0.2s, box-shadow 0.2s;
        }

        .task-item:hover {
            transform: translateX(5px);
            box-shadow: 2px 2px 8px rgba(0,0,0,0.1);
        }

        .task-text {
            flex: 1;
            margin: 0 15px;
        }

        .delete-btn {
            padding: 6px 12px;
            background-color: #ff4444;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            opacity: 0.8;
            transition: opacity 0.2s;
        }

        .delete-btn:hover {
            opacity: 1;
        }

        /* 空状态提示 */
        .empty-state {
            text-align: center;
            color: #666;
            padding: 20px;
            display: none;
        }

        /* 动画效果 */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .task-item {
            animation: fadeIn 0.3s ease-out;
        }
    </style>
</head>
<body>
    <div class="todo-container">
        <div class="input-group">
            <input type="text" id="taskInput" placeholder="输入新任务...">
            <button id="addButton">添加任务</button>
        </div>
        <div class="empty-state" id="emptyState">当前没有任务，开始添加吧！</div>
        <ul id="taskList"></ul>
    </div>

    <script>
        // DOM元素
        const taskInput = document.getElementById('taskInput');
        const addButton = document.getElementById('addButton');
        const taskList = document.getElementById('taskList');
        const emptyState = document.getElementById('emptyState');

        // 添加任务函数
        function addTask() {
            const taskText = taskInput.value.trim();
            
            if (!taskText) {
                taskInput.focus();
                return;
            }

            // 创建新任务项
            const li = document.createElement('li');
            li.className = 'task-item';
            
            li.innerHTML = `
                <span class="task-text">${taskText}</span>
                <button class="delete-btn">删除</button>
            `;

            // 添加删除功能
            li.querySelector('.delete-btn').addEventListener('click', () => {
                li.remove();
                updateEmptyState();
            });

            // 添加动画效果
            li.style.animation = 'fadeIn 0.3s ease-out';
            
            taskList.appendChild(li);
            taskInput.value = '';
            taskInput.focus();
            updateEmptyState();
        }

        // 更新空状态提示
        function updateEmptyState() {
            emptyState.style.display = taskList.children.length ? 'none' : 'block';
        }

        // 事件监听
        addButton.addEventListener('click', addTask);
        taskInput.addEventListener('keypress', (e) => {
            if (e.key === 'Enter') addTask();
        });

        // 初始化空状态
        updateEmptyState();
    </script>
</body>
</html>